using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace LS.GameKit
{
    public class Trigger3DBehaviour : Physics3DBehaviour
    {
        private void OnTriggerEnter(Collider collider)
        {
            if (!castTrigger && collider.isTrigger) return;
            if (!castCollision && !collider.isTrigger) return;
            if (!castLayers.LayerCast(1 << collider.gameObject.layer)) return;
            var result = new Trigger3DInfo(collider);
            DoEnter(result);
        }

        private void OnTriggerStay(Collider collider)
        {
            var result = FindResult(collider);
            if (result != null)
            {
                DoUpdate(result);
            }
        }

        private void OnTriggerExit(Collider collider)
        {
            var result = FindResult(collider);
            if (result != null)
            {
                DoExit(result);
            }
        }
    }
}
